﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<Pp.UI.Models.ProjectDetailViewModel>" %>

<%@ Import Namespace="Pp.Globalization" %>
<%@ Import Namespace="Pp.Core.Extentions" %>
<%@ Import Namespace="Pp.UI.Models" %>
<%@ Import Namespace="Pp.Dto" %>
<%@ Import Namespace="System.IO" %>
<%@ Register Src="../Shared/ShareThis.ascx" TagName="ShareThis" TagPrefix="uc1" %>
<asp:Content ID="Content4" ContentPlaceHolderID="ScriptContent" runat="server">
    <meta name="description" content="<%=Model.Detail.SmallDescription %>">
    <meta name="Abstract" content="<%=Model.Detail.Name %>">
</asp:Content>
<asp:Content ID="Content1" ContentPlaceHolderID="MiddleWall" runat="server">
    <div id="tabs">
        <ul>
            <li><a href="#detail"><%=Res.Label_Detail %></a></li>
            <li><a href="#attach"><%=Res.Label_Files %></a></li>
            <li><a href="#pictures"><%=Res.Label_Images %></a></li>
            <li><a href="#comments"><%=Res.Label_Comments %>(<%:Model.Detail.Comments.Count%>
                )</a></li>
        </ul>
        <div id="detail">
            <h2>
                <%=Model.Detail.Name %></h2>
            <p class="project-detail">
                <!-----------SHARE THIS------------->
                <uc1:ShareThis ID="ShareThis1" runat="server" />
                <!----------- /SHARE THIS------------->
                <%=Server.HtmlDecode(Model.Detail.SmallDescription)%><br />
                <hr />
                <%=Server.HtmlDecode(Model.Detail.Description)%><br />
                <span class="general-information"><span class="general-information-title">
                    <%=Res.Label_Category%></span><a href="/Home/Index?c=<%=Model.Detail.Category.CategoryId %>"><%=Model.Detail.Category.Category%></a>
                </span>
                <%if (!string.IsNullOrEmpty(Model.Detail.SignatureCollect))
                  {%>
                <center>
                    <a href="http://imza.la/<%=Model.Detail.SignatureCollect %>">
                        <iframe src="http://imza.la/widget/?id=<%=Model.Detail.SignatureCollect
    %>&s=468&bg=EAF1FB&br=9BBBEC&t=001166&d=111111&format=frame" width="468" height="60" frameborder="0"
                            scrolling="no"></iframe>
                    </a>
                </center>
                <%} %>
            </p>
        </div>
        <div id="attach">
            <%if (Model.IsMyProject)
              {%>
            <%Html.RenderPartial("UploadFile", new
    UploadProject { Id = Model.Detail.Id, File = null }); %>
            <%} %>
            <%Html.RenderAction("GetFiles",
    "Project", new RouteValueDictionary { { "Id", Model.Detail.Id } });%>
        </div>
        <div id="pictures">
            <%if (Model.IsMyProject)
              {%>
            <%Html.RenderPartial("UploadImage",
    new UploadProject { Id = Model.Detail.Id, File = null }); %>
            <%} %>
            <%Html.RenderAction("GetImages",
    "Project", new RouteValueDictionary { { "Id", Model.Detail.Id } });%>
        </div>
        <div id="comments">
            <%if (Request.IsAuthenticated)
              {%>
            <form id="form1" runat="server">
            <%Html.RenderPartial("FormValidateControlScripts"); %>
            </form>
            <!-----------Comment------------->
            <%Html.RenderPartial("ProjectComment",
    new Dictionary<Guid, string> { { Model.Detail.Id, "commentList" } }); %>
            <%} %>
            <%if (Model.Detail.Comments.Count != 0)
              {%>
            <div id="commentList">
                <%foreach (var
    comment in Model.Detail.Comments)
                  {%>
                <div class="sent-comments">
                    <div class="comment-user-picture">
                        <p>
                            <img width="35" src="<%=comment.WhoIs.Id.ToSmallImageString(ImageType.Profile)
    %>" /></p>
                    </div>
                    <div class="comment-content">
                        <p class="comment-p">
                            <span class="comment-sender-name"><a href="/Profile/Index/<%=comment.WhoIs.Username %>">
                                <%=comment.WhoIs.GetFullName()
                                %></a> </span>
                            <%=comment.Comment.ToBreakSpan(60)%>
                        </p>
                        <p class="comment-createdate">
                            <span>
                                <img src="/Content/themes/Theme1/images/blogadd.png" /></span>
                            <%=comment.CreateDate.ToUserTimeString()
                            %></p>
                    </div>
                    <div class="delete-comment">
                        <!--------COMMENT DELETE--------->
                        <span class="delete-comment" style="color: Red;">
                            <% if (Model.IsMyProject || comment.WhoIs.Username
    == User.Identity.Name)
                               {%>
                            <%Html.RenderPartial("DeleteForm", new DeleteFormItem(Url.Action("CommentDelete", "Project"), comment.Id));%>
                            <%}%></span>
                    </div>
                    <div style="clear: both">
                    </div>
                </div>
                <%} %>
            </div>
            <%} %>
            <!-----------Comment------------->
        </div>
    </div>
    <script>
        $(document).ready(function () {
            $("#tabs").tabs();
        });
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="LeftWall" runat="server">
    <img src="<%=Model.Detail.Image.ExistImage(Server,ImageType.Project) %>" width="200" />
    <ul class="Profil_Menu">
        <%if (Model.IsMyProject && Request.IsAuthenticated)
          {%>
        <li><a href="<%: Url.Action("Edit", "Project",new{Model.Detail.Id})%>"><span>
            <img src="/Content/themes/Theme1/images/edit-project2.png" /></span>
            <%=Res.Title_Project_Edit%>
        </a></li>
        <li><a href="<%: Url.Action("Index", "Angel",new{Model.Detail.Id})%>"><span>
            <img src="/Content/themes/Theme1/images/image-edit.png" /></span>
            <%=Res.Label_Edit_Angel%>
        </a></li>
        <%} %>
        <%if (!Model.IsMyProject && Request.IsAuthenticated)
          { %>
        <ul class="like-follow">
            <li>
                <%Html.RenderPartial("Like", new MLike
                                                  {
                                                      Id = Model.Detail.Id,
                                                      Like = Model.Detail.Likes.All(d => d.UserDetail.Username != User.Identity.Name),
                                                      LikeType = LikeType.Project,
                                                      ChangeCount = ".likeCount"

                                                  });%>
            </li>
            <li>
                <%Html.RenderPartial("Follow", new FollowItem
                                              {
                                                  FollowType = FollowType.Project,
                                                  Id = Model.Detail.Id,
                                                  FollowCount = ".followCount",
                                                  IsFollow = Model.Detail.Followers.All(d => d.Follower.Username != User.Identity.Name)
                                              }); %>
            </li>
        </ul>
        <%if (Model.Detail.AllowAngelRequest)
          {%>
        <% if (Model.Detail.AngelRequests.Count(d => d.User.Username == User.Identity.Name && d.State != AngelRequestStateDto.Cancel) == 0)
           {%>
        <form class="angelRequestCreate" method="post">
        <%=Html.AntiForgeryToken() %>
        <input type="hidden" name="projectId" value="<%=Model.Detail.Id %>" />
        <p>
            <a href="#" class="angelRequest">
                <%=Res.Label_Suggest_Angel%></a></p>
        </form>
        <%}%>
        <% if (Model.Detail.AngelRequests.Any(d => d.User.Username == User.Identity.Name && d.State != AngelRequestStateDto.Cancel))
           {%>
        <form class="cancelForm" method="post">
        <input type="hidden" name="angelRequest" value="<%=Model.Detail.AngelRequests.First(d => d.User.Username == User.Identity.Name).Id%>" />
        <input type="hidden" name="returnUrl" value="<%=Request.Url%>" />
        <%=Html.AntiForgeryToken()%>
        <p>
            <a href="#" class="angelRequestCancel">
                <%=Res.Label_Cancel_AngelRequest %></a></p>
        </form>
        <%}%>
        <%} %>
        <%}%>
        <li class="red"><b>
            <%=Res.Label_Project_Cost %>
            :</b><%=Model.Detail.ProjectCost %>
            ' TL </li>
    </ul>
    <%Html.RenderPartial("UserCardRead", Model.Detail.User); %>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="RightWall" runat="server">
    <div class="status-box">
        <h4 class="pink">
            <%=Res.Title_Followers%>
            <a class="followCount">
                <%=Model.Detail.Followers.Count()%>
            </a>
        </h4>
        <%Html.RenderPartial("UserSmallList", Model.Detail.Followers.Select(d => d.Follower).ToList()); %>
    </div>
    <div class="status-box">
        <h4 class="pink">
            <%=Res.Title_Likes %>
            <a class="likeCount">
                <%=Model.Detail.Likes.Count()%></a></h4>
        <%Html.RenderPartial("UserSmallList", Model.Detail.Likes.Select(d => d.UserDetail).ToList()); %>
    </div>
    <%if (Model.IsMyProject && Request.IsAuthenticated)
      {%>
    <h4>
        <%=Res.Title_angels %></h4>
    <p>
        <span>Sponsor <a href='/Angel/Create/<%=Model.Detail.Id %>'>
            <%=Res.Label_Create  %></a></span>
        <br />
        <%=Model.Detail.Angels.Count() == 0 ? Res.Label_No_Angel : ""%>
    </p>
    <%}
      else
      {%>
    <h4>
        <%=Res.Title_angels  %></h4>
    <p class="red">
        <%=!Model.Detail.Angels.Any() ? Res.Label_No_Angel : ""%><br />
        <%} %>
        <ul class="angels-list">
            <%foreach (var angelDto in Model.Detail.Angels)
              {%>
            <li>
                <h5>
                    <%=angelDto.Name %></h5>
                <img src="<%=angelDto.Id.ToMediumImageString(ImageType.Angel).ExistImage(Server,ImageType.Angel) %>"
                    width="100" /><br />
                <p>
                    <%=angelDto.Description %></p>
            </li>
            <%} %>
        </ul>
    </p>
    <h4>
        <%=Res.Title_Angel_member%></h4>
    <ul class="angels-list">
        <%foreach (var angelDto in Model.Detail.AngelRequests.Where(d => d.State != AngelRequestStateDto.Cancel))
          {%>
        <li style="list-style-type: none;" class="request <%=angelDto.State.ToString() %>"
            title="<%=angelDto.ToStateString%>">
            <%if (angelDto.State == AngelRequestStateDto.Appro && (Model.IsMyProject || angelDto.User.Username == User.Identity.Name))
              {%>
            <form class="cancelForm" method="post">
            <input type="hidden" name="angelRequest" value="<%=angelDto.Id%>" />
            <input type="hidden" name="returnUrl" value="<%=Request.Url%>" />
            <%=Html.AntiForgeryToken()%>
            <p>
                <a href="#" class="angelRequestCancel" title="<%=Res.Label_Cancel %>" alt="<%=Res.Label_Cancel %>">
                    x</a></p>
            </form>
            <%} %>
            <%if (angelDto.State != AngelRequestStateDto.Appro && (Model.IsMyProject))
              {%>
            <form class="approForm" method="post">
            <input type="hidden" name="angelRequest" value="<%=angelDto.Id%>" />
            <input type="hidden" name="returnUrl" value="<%=Request.Url%>" />
            <%=Html.AntiForgeryToken()%>
            <p><a href="#" class="angelRequestAppro">√</a></p>
            </form>
            <%} %>
            <%Html.RenderPartial("UserCardRead", angelDto.User); %>
        </li>
        <%} %>
    </ul>
    <script type="text/javascript" language="javascript">
        $(".angelRequest").click(function () {
            $.post('<%=Url.Action("NewRequest","Angel") %>',
              $(this).parent().parent().serialize(),
               function (data) {
                   if (!data.Success) {
                       alert(data.Error);
                   }
                   else {

                       document.location = document.URL;
                   }
               });
            $(this).html('<%=Res.Message_Complateing_Application %>');
        });
        $(".angelRequestCancel").click(function () {
            $.post('<%=Url.Action("CancelRequest","Angel") %>',
               $(this).parent().parent().serialize(),
               function (data) {
                   if (!data.Success) {
                       alert(data.Error);
                   }
                   else {
                       document.location = document.URL;
                   }
               })
            $(this).html('<%=Res.Message_Canceling %>');
        });
        $(".angelRequestAppro").click(function () {
            $.post('<%=Url.Action("ApproRequest","Angel") %>',
               $(this).parent().parent().serialize(), function (data) {
                   if (!data.Success) {
                       alert(data.Error);
                       return;
                   }
                   document.location = document.URL;
               });
            $(this).html('<%=Res.Message_Checking %>');
        });
    </script>
</asp:Content>
